package com.xinxin.leetcode.problem461;

/**
 * @author ShiXinXin
 * @date 2020-01-04 20:11
 */
class Solution {
    private int oneNumber(int num) {
        int res = 0;
        while (num > 0) {
            num = num & (num - 1);
            res++;
        }
        return res;
    }

    public int hammingDistance(int x, int y) {
        return oneNumber(x ^ y);
    }

    public static void main(String[] args) {
        System.out.println(new Solution().hammingDistance(1, 4));
    }
}
